Skip to content

Conversation

@AustinChangLinksys
Copy link
Collaborator

@AustinChangLinksys AustinChangLinksys commented Jan 9, 2026

User description

Summary

Encapsulated all platform-specific conditional imports into entry point files, eliminating exposed if (dart.library.*) patterns in consumer files.

Changes

New Entry Point Files Created (7 files)

  • lib/core/utils/ip_getter/ip_getter.dart
  • lib/util/url_helper/url_helper.dart (refactored)
  • lib/util/export_selector/export_selector.dart
  • lib/util/get_log_selector/get_log_selector.dart
  • lib/constants/client_type/client_type.dart
  • lib/core/utils/assign_ip/assign_ip.dart
  • lib/core/utils/assign_ip/mobile_assign_ip.dart (no-op native impl)

Consumer Files Updated (17 files)

All consumer files now use clean single-line imports instead of conditional imports.

Benefits

  • Cleaner code: Consumers only import entry point files
  • Encapsulation: Platform-specific logic hidden inside entry points
  • Maintainability: Changes to platform implementations don't affect consumers

Documentation

See doc/audit/platform-conditional-exports-audit.md for full audit report.

Verification

  • flutter analyze passes
  • flutter build web succeeds
  • All tests pass (2701 tests)

Related Issue

Closes #582


PR Type

Enhancement


Description

  • Encapsulate platform-specific conditional imports into 7 new entry point files

  • Update 17 consumer files to use clean single-line imports instead of conditional logic

  • Add comprehensive audit documentation for platform conditional exports and service decoupling

  • Update UI kit library dependency from v2.10.3 to v2.10.4


Diagram Walkthrough

flowchart LR
  A["Consumer Files<br/>17 files"] -->|"Clean single import"| B["Entry Point Files<br/>7 new files"]
  B -->|"Conditional export<br/>if dart.library.*"| C["Platform Implementations<br/>Mobile/Web/Stub"]
  D["Documentation<br/>2 audit reports"] -.->|"Verifies"| B
  style A fill:#e1f5ff
  style B fill:#fff3e0
  style C fill:#f3e5f5
  style D fill:#e8f5e9
Loading

File Walkthrough

Relevant files
Enhancement
24 files
ip_getter.dart
New entry point for IP getter module                                         
+17/-0   
url_helper.dart
Refactored to entry point with conditional exports             
+19/-2   
url_helper_stub.dart
New stub implementation for URL helper                                     
+2/-0     
assign_ip.dart
New entry point for assign IP module                                         
+19/-0   
mobile_assign_ip.dart
New no-op mobile implementation for assign IP                       
+14/-0   
export_selector.dart
New entry point for export selector module                             
+17/-0   
get_log_selector.dart
New entry point for get log selector module                           
+17/-0   
client_type.dart
New entry point for client type constants                               
+17/-0   
cloud_const.dart
Update to use client_type entry point                                       
+1/-3     
url_links.dart
Update to use url_helper entry point                                         
+1/-3     
linksys_cloud_repository.dart
Update to use ip_getter entry point                                           
+1/-3     
linksys_device_cloud_service.dart
Update to use ip_getter entry point                                           
+1/-3     
router_repository.dart
Update to use ip_getter entry point                                           
+1/-3     
internet_settings_view.dart
Update to use assign_ip entry point                                           
+1/-2     
bridge_form.dart
Update to use url_helper entry point                                         
+1/-3     
local_network_settings_view.dart
Update to use assign_ip entry point                                           
+1/-2     
external_speed_test_links.dart
Update to use url_helper entry point                                         
+1/-3     
wifi_card.dart
Update to use export_selector entry point                               
+1/-3     
dashboard_home_view.dart
Update to use assign_ip entry point                                           
+1/-2     
speed_test_external.dart
Update to use url_helper entry point                                         
+1/-3     
speed_test_external_widget.dart
Update to use url_helper entry point                                         
+1/-3     
manual_firmware_update_provider.dart
Update to use ip_getter entry point                                           
+1/-3     
router_provider.dart
Update to use ip_getter entry point                                           
+1/-3     
utils.dart
Update to use export and log selector entry points             
+2/-6     
Documentation
2 files
platform-conditional-exports-audit.md
Comprehensive audit report for platform conditional exports
+287/-0 
service-decoupling-audit.md
Service decoupling audit documenting JNAP coupling status
+259/-0 
Dependencies
1 files
pubspec.yaml
Update UI kit library dependency to v2.10.4                           
+2/-2     

- Create entry point files for 7 modules:
  - ip_getter, url_helper, export_selector, get_log_selector,
    client_type, assign_ip (new entry points)
- Add mobile_assign_ip.dart (no-op implementation for native)
- Update 17 consumer files to use clean single imports
- Add platform-conditional-exports-audit.md documentation

This eliminates exposed conditional imports in consumer files.
Consumers now only need to import the entry point file.

Modules encapsulated:
1. ip_getter (5 consumers)
2. url_helper (5 consumers)
3. export_selector (2 consumers)
4. get_log_selector (1 consumer)
5. client_type (1 consumer)
6. assign_ip (3 consumers)
@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Stub throws error: openUrl throws UnimplementedError on unsupported platforms without an in-function
fallback, so callers may crash unless every call site guards or handles the exception.

Referred Code
void openUrl(String url) =>
    throw UnimplementedError('[Platform Error] Not implemented');

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status:
Error detail exposed: The thrown UnimplementedError message includes platform/implementation detail ([Platform
Error] Not implemented) that could be shown to end users if not caught and mapped to a
generic UI error.

Referred Code
void openUrl(String url) =>
    throw UnimplementedError('[Platform Error] Not implemented');

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Add assertions for platform misuse

In mobile_assign_ip.dart, add assert(false, ...) to the no-op functions
(assignWebLocation, updateWebHost, reload) to alert developers if these
web-specific functions are incorrectly called on native platforms during debug
builds.

lib/core/utils/assign_ip/mobile_assign_ip.dart [4-14]

 void assignWebLocation(String url) {
+  assert(false, 'assignWebLocation should not be called on native platforms');
   // No-op on native - this is a web-specific operation
 }
 
 void updateWebHost(String host) {
+  assert(false, 'updateWebHost should not be called on native platforms');
   // No-op on native - this is a web-specific operation
 }
 
 void reload() {
+  assert(false, 'reload should not be called on native platforms');
   // No-op on native - this is a web-specific operation
 }
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that silent no-op functions can hide bugs and proposes using assertions to provide immediate feedback during development, which improves code robustness and maintainability.

Low
  • More

@PeterJhongLinksys PeterJhongLinksys merged commit 54cc9c9 into dev-2.0.0 Jan 13, 2026
2 checks passed
@PeterJhongLinksys PeterJhongLinksys deleted the austin/platform-conditional-exports-encapsulation branch January 13, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants